<!doctype html>
<meta charset="utf-8">
<title>WebSQL: FTS3 Pointer Leak in bug 742407</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
'use strict';

async_test(testCase => {
  const database = openDatabase(
      'Fts3PointerLeakTest', '1.0', 'Database for FTS3 pointer leak test',
      1024 * 1024);
  assert_not_equals(database, null, 'openDatabase should not fail');

  database.transaction(testCase.step_func(transaction => {
    transaction.executeSql(
        'DROP TABLE IF EXISTS main;', [], () => {},
        testCase.unreached_func('FTS3 table drop should not fail'));
    transaction.executeSql(
        'CREATE VIRTUAL TABLE main USING FTS3(fts3table);', [], () => {},
        testCase.unreached_func('FTS3 table creation should not fail'));
    transaction.executeSql(
        "INSERT INTO main VALUES (x'0000000000000000');", [], () => {},
        testCase.unreached_func('FTS3 table insertion should not fail'));

    transaction.executeSql(
        'SELECT hex(main) AS h FROM main;', [],
        testCase.step_func((_, result) => {
          assert_equals(result.rows.item(0).h, '');
          testCase.done();
        }), testCase.unreached_func('FTS3 select should not fail'));

  }));
}, `SELECT should not return the value of an FTS3 pointer column`);

</script>
